import React from 'react';
import { IndexRoute, Route } from 'react-router';
import Container from '../DumbContainer';
import CompanyListContainer from './CompanyListComponent';
import CompanyDetailContainer from './CompanyDetailComponent';
import ViewerQuery from "../../routes/ViewerQuery";

const defaultPrepareParams = (params, { location }) => {
  return ({ ...params, ...location.query });
};

const router = (
  <Route path='/company' queries={ViewerQuery} component={Container}>
    <IndexRoute component={CompanyListContainer} queries={ViewerQuery}/>
    <Route
      key=":companyId"
      path=":companyId"
      component={CompanyDetailContainer}
      queries={ViewerQuery}
      prepareParams={defaultPrepareParams}
    />
  </Route>
);

export default router;
